##
description = "AI 导航站点"
title = "AI 导航站点"
==
<?

function onEnd()
{
    // Main Category Query
    $config = $this['options'];

    $limit = isset($config['widget_category_count'])? intval($config['widget_category_count']): 12;
    $categories = RainLab\Blog\Models\Category::withCount('posts')
        ->where('parent_id','=',  NULL)
        ->orderBy('posts_count', 'DESC')
        ->limit($limit);
        
    $this['widget_categories'] = $categories->get()->all();

    $cacheFile = storage_path().'/home_post.cache';
    $fileContent = file_get_contents($cacheFile);
    $all_posts = json_decode($fileContent, true);

    $this['all_posts'] = $all_posts;

    //hot tag
    $tag = RainLab\Blog\Models\Tag::withCount('posts')
        ->where('id','=',  $this->theme->hot_posts)
        ->orderBy('posts_count', 'DESC')
        ->limit(3)
        ->get()->all();

    $this['hot_posts'] = [];
    if (!empty($tag)) {
        $this['hot_posts'] = $tag[0]['posts'];
    }

    //recommend tag
    $tag = RainLab\Blog\Models\Tag::withCount('posts')
        ->where('id','=',  $this->theme->recommend_posts)
        ->orderBy('posts_count', 'DESC')
        ->limit($limit)
        ->get()->all();

    $this['recommend_posts'] = [];
    if (!empty($tag)) {
        $this['recommend_posts'] = $tag[0]['posts'];
    }

    //banner tag
    $tag = RainLab\Blog\Models\Tag::withCount('posts')
        ->where('id','=',  $this->theme->banner_posts)
        ->orderBy('posts_count', 'DESC')
        ->limit($limit)
        ->get()->all();

    $this['banner_posts'] = [];
    if (!empty($tag)) {
        $this['banner_posts'] = $tag[0]['posts'];
    }
}
?>

==
<!DOCTYPE html>
<html>
    <head>
        {% partial 'site/meta' %}
        

        <link href="{{ 'assets/css/libs.min.css'|theme }}" rel="stylesheet">
        <link href="{{ 'assets/css/main.css'|theme }}" rel="stylesheet">

        <link href="https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900&display=swap" rel="stylesheet">
        <link href="https://fonts.googleapis.com/css2?family=Marcellus&display=swap" rel="stylesheet">

        {% styles %}
    </head>
    <body class="page-home">

        <!-- Header -->
        <header id="layout-header">
            {% partial 'site/header' %}
        </header>

        <!-- Content -->
        <div class="page-wrapper">
            {% partial 'site/logo' %}
            <div class="page-content">
                {% partial 'site/silder' %}
                <main class="page-main">
                    <div class="uk-grid" data-uk-grid>
                        
                        <div class="uk-width-2-3@l uk-width-3-3@m uk-width-3-3@s">
                            <h3 class="uk-text-lead">最近更新</h3>
                            <div class="js-recommend">
                                <div class="swiper">
                                    <div class="swiper-wrapper">
                                        {% for item in banner_posts %}
                                        <div class="swiper-slide">
                                            <div class="recommend-slide">
                                                <div class="tour-slide__box">
                                                    <a target="_blank" href="{{ item.source_url | default('') }}"><img src="{{ item.featured_images[0].path | default('') }}" alt="banner"></a>

                                                </div>
                                            </div>
                                        </div>
                                        {% endfor %}
                                        
                                    
                                    </div>
                                    <div class="swipper-nav">
                                        <div class="swiper-button-prev"></div>
                                        <div class="swiper-button-next"></div>
                                    </div>
                                    <div class="swiper-pagination"></div>
                                </div>
                            </div>
                        </div>
                        <div class="uk-width-1-3@l uk-width-3-3@m uk-width-3-3@s">
                            <h3 class="uk-text-lead">推荐AI应用</h3>
                            <div class="widjet__body">
                                <ul class="uk-grid-small uk-child-width-1-1 uk-child-width-1-1@xl uk-child-width-1-1@l uk-child-width-1-1@m uk-child-width-1-1@s" data-uk-grid>
                                        {% for item in hot_posts %}
                                        <li data-type="{{ item.categories[0].id|default('') }}">
                                            <div class="game-card --horizontal --small">
                                                <div class="game-card__box">
                                                    <div class="game-card__media"><a href="/blog/post/{{ item.slug }}"><img src="{{ item.featured_images[0].path | default('') }}" alt="{{ item.name | default(item.slug | title) }}" /></a></div>
                                                    <div class="game-card__info"><a class="game-card__title" href="/blog/post/{{ item.slug }}"> {{ item.title | default(item.slug | title) }}</a>
                                                        <div class="game-card__discussion">{{ item.excerpt | default(item.title | title) }}</div>
                                                    </div>
                                                    
                                                </div>
                                            </div>

                                        </li>
                                        {% endfor %}
                                    </ul>
                            </div>
                        </div>

                        <div class="uk-width-1-1@l">
                            <div class="widjet --my-list">
                                <div class="widjet__head">
                                    <h3 class="uk-text-lead">热门AI应用</h3><a href="10_game-profile.html">查看所有</a>
                                </div>
                                <div class="widjet__body">
                                    <ul class="uk-grid-small uk-child-width-1-1 uk-child-width-1-4@xl uk-child-width-1-3@l uk-child-width-1-3@m uk-child-width-1-2@s" data-uk-grid>
                                        {% for item in recommend_posts %}
                                        <li data-type="{{ item.categories[0].id|default('') }}">
                                            <div class="game-card --horizontal --small">
                                                <div class="game-card__box">
                                                    <div class="game-card__media"><a href="/blog/post/{{ item.slug }}"><img src="{{ item.featured_images[0].path | default('') }}" alt="{{ item.name | default(item.slug | title) }}" /></a></div>
                                                    <div class="game-card__info"><a class="game-card__title" href="/blog/post/{{ item.slug }}"> {{ item.title | default(item.slug | title) }}</a>
                                                        <div class="game-card__discussion">{{ item.excerpt | default(item.title | title) }}</div>
                                                    </div>
                                                    
                                                </div>
                                            </div>

                                        </li>
                                        {% endfor %}
                                    </ul>
                                </div>
                            </div>
                        </div>

                        <!-- list -->
                        {% for category in widget_categories %}
                        <div class="uk-width-1-1 uk-first-column">
                            <a name="{{ category.id }}">
                                <h3 class="uk-text-lead">{{ category.name | default(tag.slug | title) }}</h3></a>
                            <div data-uk-filter="target: .js-filter">
                                <ul class="uk-subnav uk-subnav-pill">
                                    <li class="uk-active" data-uk-filter-control><a href="#">All</a></li>
                                    {% for child in category.children|default([]) %}

                                        <li data-uk-filter-control="[data-type='{{ child.id}}']"><a href="#">{{ child.name | default(tag.slug | title) }}</a></li>
                                    {% endfor %}
                                </ul>
                                {% set categoryPostList = all_posts[category.id]|default([]) %}
                                <ul class="js-filter uk-grid-small uk-child-width-1-1 uk-child-width-1-4@xl uk-child-width-1-3@l uk-child-width-1-3@m uk-child-width-1-2@s" data-uk-grid>
                                    {% for item in categoryPostList %}
                                    <li data-type="{{ item.categories[0].id|default('') }}">
                                        <div class="game-card --horizontal --small">
                                            <div class="game-card__box">
                                                <div class="game-card__media"><a href="/blog/post/{{ item.slug }}"><img src="{{ item.featured_images[0].path | default('') }}" alt="{{ item.name | default(item.slug | title) }}" /></a></div>
                                                <div class="game-card__info"><a class="game-card__title" href="/blog/post/{{ item.slug }}"> {{ item.title | default(item.slug | title) }}</a>
                                                    <div class="game-card__discussion">{{ item.excerpt | default(item.title | title) }}</div>
                                                </div>
                                                
                                            </div>
                                        </div>

                                    </li>
                                    {% endfor %}
                                </ul>
                            </div>
                        </div>
                        {% endfor %}

                    </div>


                    <!-- Footer -->
                    <footer id="layout-footer">
                        {% partial 'site/footer' %}
                    </footer>

                </main>
            </div>
        </div>
        {% partial 'site/support' %}

        <!-- Scripts -->
        <script src="{{ 'assets/js/libs.js'|theme }}"></script>
        <script src="{{ 'assets/js/main.js'|theme }}"></script>

        {% snowboard all %}
        {% scripts %}
        {% partial 'site/scripts' %}

    </body>
</html>
